package com.woniu.adapter;

import com.woniu.outlet.mysql.dao.NoticeDao;
import com.woniu.outlet.mysql.po.Notice;
import com.woniu.outlet.mysql.po.NoticeExample;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class NoticeRepositoryApater {
    @Autowired
    private NoticeDao noticeDao;

    //添加通知
    public void add(Notice notice) {
        noticeDao.insert(notice);
    }

    //根据[用户id]用户查询通知，按时间排序查询
    public List<Notice> getByUserId(NoticeExample example) {
        List<Notice> notices = noticeDao.selectByExample(example);
        return notices;
    }

    //更新
    public void update(Notice notice) {
        noticeDao.updateByPrimaryKey(notice);
    }

    //根据通知id查询
    public Notice getById(Integer id) {
        Notice notice = noticeDao.selectByPrimaryKey(id);
        return notice;
    }
}